package com.zws.cucumber.expander;

import com.zws.cucumber.util.colorfullog.ZwsColorfulLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;

/**
 * author: zws
 */
public class ZwsStrFunctionUtil {

    private static final Logger logger = ZwsColorfulLogger.of(LoggerFactory.getLogger(ZwsStrFunctionUtil.class));

    public static final Map<String, BiFunction<Boolean, Object[], Object>> functionMap = new HashMap<>();

    public static void registerFunction(String functionName, BiFunction<Boolean, Object[], Object> function) {
        if (ZwsStrFunctionUtil.functionMap.putIfAbsent(functionName, function) != null) {
            logger.warn("<y>function existed: {}</y>", functionName);
        }
    }
}
